package bb.lanxing.model.json;

import android.os.Parcel;
import android.os.Parcelable;

import com.alibaba.fastjson.annotation.JSONField;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

import bb.lanxing.util.JsonUtil;


public class Channel implements Parcelable, Serializable {
    public static final Creator<Channel> CREATOR = new Creator<>() { 
        @Override 
        public Channel createFromParcel(Parcel parcel) {
            return new Channel(parcel);
        }

        @Override 
        public Channel[] newArray(int i) {
            return new Channel[i];
        }
    };
    private static final long serialVersionUID = 1;
    @JSONField(serialize = false)
    private String description;
    private String name;
    @JSONField(name = "id")
    private int serverId;
    @JSONField(serialize = false)
    private boolean showNearby;
    @JSONField(serialize = false)
    private long topicCount;
    @JSONField(serialize = false)
    private long viewCount;

    @Override 
    public int describeContents() {
        return 0;
    }

    public Channel() {
    }

    public Channel(JSONObject jSONObject) throws JSONException {
        setServerId(JsonUtil.getIntegerValue("id", jSONObject));
        setName(JsonUtil.getStringValue("name", jSONObject));
        setDescription(JsonUtil.getStringValue("description", jSONObject));
        setViewCount(JsonUtil.getLongValue("view_count", jSONObject));
        setTopicCount(JsonUtil.getLongValue("topic_count", jSONObject));
    }

    public long getViewCount() {
        return this.viewCount;
    }

    public void setViewCount(long j) {
        this.viewCount = j;
    }

    public long getTopicCount() {
        return this.topicCount;
    }

    public void setTopicCount(long j) {
        this.topicCount = j;
    }

    public int getServerId() {
        return this.serverId;
    }

    public void setServerId(int i) {
        this.serverId = i;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String str) {
        this.name = str;
    }

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String str) {
        this.description = str;
    }

    public boolean isShowNearby() {
        return this.showNearby;
    }

    public void setShowNearby(boolean z) {
        this.showNearby = z;
    }

    @Override 
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeInt(this.serverId);
        parcel.writeString(this.name);
        parcel.writeString(this.description);
        parcel.writeByte(this.showNearby ? (byte) 1 : (byte) 0);
        parcel.writeLong(this.viewCount);
        parcel.writeLong(this.topicCount);
    }

    protected Channel(Parcel parcel) {
        this.serverId = parcel.readInt();
        this.name = parcel.readString();
        this.description = parcel.readString();
        this.showNearby = parcel.readByte() != 0;
        this.viewCount = parcel.readLong();
        this.topicCount = parcel.readLong();
    }
}
